package com.wms.service.impl;

import com.wms.entity.Set;
import com.wms.mapper.SetMapper;
import com.wms.service.SetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SetServiceImpl implements SetService {

    @Autowired
    SetMapper setMapper;
    private List<String> categoryCodes;
    String categoryCodesStr;

    @Override
    public int saveOrUpdate(Set set) {
        //根据类型查询数据是否存在
        Integer id= setMapper.queryId(set.getType());
        int rs=0;
         if(null==id){
             //插入
             rs=setMapper.save(set);
         }else{
             //更新
             set.setId(id);
             rs=setMapper.update(set);
         }
        return rs;
    }

    @Override
    public Set queryByType(int type) {
        Set set = setMapper.queryByType(type);
        set.parseCategoryCodes();
        return set;
    }


}
